<script type='text/javascript'>
  $j(function(){
      
    $j('.reply_link').click(function(){
      cancel_reply();
      var reply = this.id;
      var indexOfSplit = reply.indexOf(':');
      var reply_id = reply.substring(5, indexOfSplit);
      var reply_name = reply.substring(indexOfSplit + 1);
      $j('#comment_comment_id').val(reply_id);
      $j('#reply_info').html("reply to " + reply_name + " <a class='cancel_reply_link' href='javascript:void(0)' onclick='cancel_reply()'>cancel</a>");
    });
  });

  function cancel_reply() {
    $j('#comment_comment_id').val('');
    $j('#reply_info').html('');
  }
</script>

<div class="post">
  <div class="post_title">
    <h2><%= link_to @post.title, "#{blog_post_path(@post)}"  %></h2>
    <span class='date_tab'><%= @post.created_at.to_s(:short) %></span>
  </div>
  <div class="post_inner">
    <%= simple_format @post.body %>
  </div>
</div>

<div id="commentslist" class="commentslist">
  <%= render :partial => 'blog/comments/commentslist' %>
</div>

<div id='post_comment'>
  <% remote_form_for [@post, Comment.new], :url => blog_post_comments_path(@post), :html => {:method => 'post'} do |f| %>
  <h4>leave your comment:</h4>
    <%= f.hidden_field :comment_id %>
    <div><%= f.text_field :name %> Name (required)</div>
    <div><%= f.text_field :email %> Email (required)</div>
    <div><span id='reply_info'></span></div>
    <div><%= f.text_area :body %></div>
    <div><%= f.submit 'Add Comment »' %></div>
  <% end %>
</div>
